Shine The Light

2017/01/11

If you want to know what's really going on, shine a light on it...

As I mentioned in the prior post, there's a powerful approach for reducing complexity that allows a significant number of objects to be removed from your system, while decreasing maintenance and subsequently improving time-to-market for new features and functionality.

Sounds almost too good to be true! Fortunately, not only is it true, but it is likely that you already leverage this technique in a limited fashion.

The Way It Used To Be

To fully describe this technique, I would first like to take you back in time. Back to the misty, barely remembered shadows of antiquity. Back to the dawn of software as we know it, maybe five years ago.

Back then, we were still connecting our systems to one-another using outdated techniques like proprietary file formats, serialized classes, fixed-length fields, proprietary web services, custom objects, specialized record formats, etc.

Back then, we didn't understand that this created tight dependencies between our systems. For example, if a proprietary file format needed to be changed, every system consuming that file format would also need to change - and change in a tightly synchronized fashion, or you would end up supporting multiple legacy formats.

Back then, we didn't understand that the dependencies between our systems were holding us back. That we were all afraid of changing our system interfaces and triggering the inevitable firestorm of flaming dominoes, with each one falling and igniting the next in a roaring inferno of expensive and disruptive change.

The Way It Is Now

We have learned a lot since then. Now, we know better. We connect our systems to one another using universal and standardized formats capable of accommodating any data structure. Today, we know how to use JSON and XML to connect our systems in a clean way that readily accommodates change.

Managing and communicating lengthy and complex inter-system communication and object standards are a thing of the past. It has all been reduced to a simple schema that is easily shared, and even can be largely ignored - except for just the pieces that you are interested in, or that are absolutely necessary.

In a matter of minutes, you can now spin up a REST interface and have the entire world happily making calls into your system with minimal documentation or fuss.

So What?

Why is this important? First, its not completely true:

Many companies continue to use legacy methods of connecting their systems, both externally and internally.

And here's the big one:

It's all a hierarchy. It is literally objects all the way down.

For all of the same reasons that virtually everyone is now using REST with JSON to implement system interfaces, the same benefits can be realized For any software object, including internal components, packages, namespaces, classes, files, configuration, tables, records, fields, properties, databases, etc.

And the icing on the cake:

It's easy to implement. In fact, it is easier to implement that what we have been doing.

Transparency

"It's gotta be transparent to let the light through!"

Proper implementation of this technique first involves a more complete understanding of what we are actually doing when we implement a JSON REST service, which is just an implementation of Transparency.

Transparency is:

The ability of an object to allow its inputs to be passed through to its outputs – even when the inputs change unpredictably.

Transparency allows objects to be "transparent" to data. This is extremely desirable in multiple ways, allowing the object:

As a result of these benefits:

Implementation of Transparency

There are a number of ways to implement transparency in any system. In all cases, we gain the benefits of decoupled components, improved extensibility, better accommodation of change, and elimination of custom data formats, custom objects and/or custom interfaces.

Transparency in interfaces is being adopted rapidly. It is likely that you are familiar with one or more of the following implementations:

The Universal DTO

One of the most effective ways of implementing transparency is by replacing DTO's (data transfer objects) with a universal DTO (such as some form of JSON object).

Custom DTO's represent a particularly insidious form of technical debt and dependency.

This is because they were once absolutely essential for bridging the gap between proprietary interfaces and your own internal environment, and preventing a complicated proprietary interface from "poisoning" your pristine internal systems. Because of this, we were all taught to make vast numbers of them.

Sadly, it is even common practice for DTO's to fully surround a transparent interface (such as a REST/JSON interface) and thereby nullify much of the benefit of using JSON in the first place.

Consider the following standard client/server stack:

DOT Stack

Notice that data is being supplied to, and consumed from, the REST API using DTO's. This means that any changes to the data structure will also require changes to these two DTO's. This situation can be easily avoided, and the system simplified, by replacing the custom DTO's with a universal DTO, such as a JSON Object.

After all, data being supplied by the server needs to be converted from the DTO to JSON anyway. Likewise, on the client side, the data needs to be converted yet again into a DTO.

In their purest form, DTO's represent just data - especially if you have done a good job of keeping them separate from your entities (models). As pure data, they are virtually name/value pairs, becoming little more than technical debt (in the form of maintenance), and are a major impediment to implementing transparency.

A Better Way

A simpler (and transparent) approach is to simply create the JSON object on the server, transmit it to the client, which then passes it on to the business logic and the view. No need to convert it twice - both to, and from, custom classes. In this way, these custom DTO's can be eliminated, while at the same time improving the transparency, simplicity, and speed of the system:

DOT Stack

But we shouldn't stop there. The business logic on each side can pass the Universal DTO through. Allowing other objects unimpeded access to the data:

DOT Stack

Now the client view is finally receiving unobstructed access to the data. On the server, the other DTO is no longer needed, since the universal DTO fulfills the same function. This further simplifies and improves our system:

DOT Stack

Also, the result of a query (a data set) is already delivered from the database in a universal form. (As long as we don't prematurely trap our data in objects via a high-maintenance framework like Hibernate or Entity Framework). It is a simple exercise to convert the result-set to JSON (in fact, many databases will already do this for us):

DOT Stack

We have now achieved a transparent stack. Not only is it simpler, more efficient, easier to understand, and easier to maintain. It also fully implements transparency. This means that a column added to the table is immediately available to be used in the view - with no code changes needed in between.

A Light at the End of the Tunnel

DOT Stack

Transparency is a powerful tool for reducing the complexity of your system by reducing both dependencies and entities, while at the same time improving performance and making future change easier to implement.

The best implementations of transparency:

Next Time

In my next post, we'll explore a number of techniques for extending the management of complexity and dependencies to teams and processes.